import java.util.Iterator;


public class FishingDerbyDriver {

	public static void main(String[] args) {
		Derby registration = new Derby("Sooke Classic");
		
		registration.register(new Bucket("Wilma", "Flintstone"));
		registration.register(new Bucket("Barney", "Rubble"));
		registration.register(new Bucket("Fred", "Flintstone"));
		
		registration.addFish(new Bucket("Fred", "Flintstone"), new Fish("Carp", 20));
		registration.addFish(new Bucket("Fred", "Flintstone"), new Fish("Salmon", 30));

		registration.addFish(new Bucket("Wilma", "Flintstone"), new Fish("Salmon", 35));
		registration.addFish(new Bucket("Wilma", "Flintstone"), new Fish("Trout", 5));

		registration.addFish(new Bucket("Barney", "Rubble"), new Fish("Trout", 7));

		Bucket winner = registration.getWinner();
		Fish biggest = winner.getBiggestFish();
		
		System.out.println("Winner is " + winner.getFirstName() + " " + winner.getLastName());
		System.out.println("with a fish " + biggest.getType() + " " + biggest.getWeight());

		System.out.println();
		System.out.println("Contestants by largest fish");
		System.out.println();
		
		for(Bucket aBucket : registration) {
			System.out.print(" " + aBucket.getFirstName() + " " + aBucket.getLastName());
			Fish aFish = aBucket.getBiggestFish();
			System.out.println(" with a fish " + aFish.getType() + " " + aFish.getWeight());		
		}
		
		System.out.println();
		System.out.println("Contestants by last name");
		System.out.println();

		Iterator<Bucket> iter = registration.iterByFirstLast();
		while(iter.hasNext()) {
			Bucket aBucket = iter.next();
			System.out.print(" " + aBucket.getFirstName() + " " + aBucket.getLastName());
			Fish aFish = aBucket.getBiggestFish();
			System.out.println(" with a fish " + aFish.getType() + " " + aFish.getWeight());		
		}
	}
}
